package com.jyl.connecter;

import com.alibaba.nacos.api.exception.NacosException;
import com.alibaba.nacos.api.naming.NamingFactory;
import com.alibaba.nacos.api.naming.NamingService;
import com.jyl.connecter.server.NettyServer;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.SpringCloudApplication;
import org.springframework.cloud.client.circuitbreaker.EnableCircuitBreaker;
import org.springframework.context.annotation.ComponentScan;

import java.net.InetSocketAddress;

@Slf4j
@ComponentScan(basePackages = {"com.jyl.connecter"})
@SpringCloudApplication
public class ConnecterApplication implements CommandLineRunner {

    @Autowired
    private NettyServer nettyServer;

    @Value("${netty.port}")
    private Integer nettyPort;

    public static void main(String[] args) {
        SpringApplication.run(ConnecterApplication.class, args);
    }

    public void run(String... args) throws Exception {
        InetSocketAddress address = new InetSocketAddress("127.0.0.1",nettyPort);
        log.info("netty服务器启动地址：{}","127.0.0.1:"+nettyPort);
        nettyServer.start(address);



    }

}
